﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using AMatysiak.Methods;

namespace AMatysiakTest.Methods
{
    [TestClass]
    public class ToEnumTest
    {
        private enum Colors
        {
            BLACK,
            BLUE,
            WHITE
        }

        [TestMethod]
        public void parseCorrect()
        {
            Colors color = Colors.BLACK;
            string colorString = color.ToString();
            Colors parsed = colorString.ToEnum<Colors>();

            Assert.AreEqual(color, parsed);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void parseIncorrect()
        {
            string colorString = "RED";
            Colors parsed = colorString.ToEnum<Colors>();
        }

        [TestMethod]
        public void parseLower()
        {
            Colors color = Colors.BLACK;
            string colorString = color.ToString().ToLower();
            Colors parsed = colorString.ToEnum<Colors>();

            Assert.AreEqual(color, parsed);
        }
    }
}
